package com.ruoyi.web.controller.jjm;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jjm.domain.CountyStatistics;
import com.ruoyi.jjm.service.ICountyStatisticsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 县统计信息Controller
 * 
 * @author tsr
 * @date 2020-07-26
 */
@Controller
@RequestMapping("/jjm/countyStatistics")
public class CountyStatisticsController extends BaseController
{
    private String prefix = "jjm/countyStatistics";

    @Autowired
    private ICountyStatisticsService countyStatisticsService;

    @RequiresPermissions("jjm:countyStatistics:view")
    @GetMapping()
    public String countyStatistics()
    {
        return prefix + "/countyStatistics";
    }

    /**
     * 查询县统计信息列表
     */
    @RequiresPermissions("jjm:countyStatistics:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CountyStatistics countyStatistics)
    {
        startPage();
        List<CountyStatistics> list = countyStatisticsService.selectCountyStatisticsList(countyStatistics);
        return getDataTable(list);
    }

    /**
     * 导出县统计信息列表
     */
    @RequiresPermissions("jjm:countyStatistics:export")
    @Log(title = "县统计信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CountyStatistics countyStatistics)
    {
        List<CountyStatistics> list = countyStatisticsService.selectCountyStatisticsList(countyStatistics);
        ExcelUtil<CountyStatistics> util = new ExcelUtil<CountyStatistics>(CountyStatistics.class);
        return util.exportExcel(list, "countyStatistics");
    }

    /**
     * 新增县统计信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存县统计信息
     */
    @RequiresPermissions("jjm:countyStatistics:add")
    @Log(title = "县统计信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CountyStatistics countyStatistics)
    {
        return toAjax(countyStatisticsService.insertCountyStatistics(countyStatistics));
    }

    /**
     * 修改县统计信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CountyStatistics countyStatistics = countyStatisticsService.selectCountyStatisticsById(id);
        mmap.put("countyStatistics", countyStatistics);
        return prefix + "/edit";
    }

    /**
     * 修改保存县统计信息
     */
    @RequiresPermissions("jjm:countyStatistics:edit")
    @Log(title = "县统计信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CountyStatistics countyStatistics)
    {
        return toAjax(countyStatisticsService.updateCountyStatistics(countyStatistics));
    }

    /**
     * 删除县统计信息
     */
    @RequiresPermissions("jjm:countyStatistics:remove")
    @Log(title = "县统计信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(countyStatisticsService.deleteCountyStatisticsByIds(ids));
    }
}
